package com.dycong.common.database.mongoDB;

import org.javers.core.Javers;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * Created by Kenti on 2015/11/16.
 */
@Component
public class JaversUtil {

    public static String user="user";
    @Resource
    Javers javers;

    private static JaversUtil javersUtil=new JaversUtil();

    public static JaversUtil getInstance(){return javersUtil;}

    /**
     * 在 saveOrUpdate 之前 进行一些设置
     * @param doLog 是否做日志记录
     * @param menuName 功能名
     */
    public void setCurrentSetp(boolean doLog, String menuName){
        if (menuName!=null){
            JaversCommitProcessor.currentUpdateMenu=menuName;
        }
        JaversCommitProcessor.doLog=doLog;
    }

    /**
     * 在 saveOrUpdate 之前 进行一些设置
     */
    public static void autoClose(boolean autoClose){
        JaversCommitProcessor.autoClose=autoClose;
        JaversCommitProcessor.doLog=autoClose;
    }

}
